$(function() {

    //begin列表信息
    $("#customerFollowRecord_datagrid").datagrid({
        url: "/customerFollowRecord/list",
        columns: [[
            {field: "xxx", checkbox: 'true'},
            {field: "id", title: "编号", width: 100,hidden:true},
            {field: "name", title: "用户名", width: 100},
            {field: "follower", title: "跟踪人员", width: 100,formatter: function(value,row,index){
                if (row.follower){
                    return row.follower.username
                } else {
                    return "";
                }
            }},
            {field: "lastFollowDate", title: "最后跟踪时间", width: 100},
            {field: "communicationPurpose", title: "交流目的", width: 100,formatter: function(value,row,index){
                if (row.communicationPurpose){
                    return row.communicationPurpose.name
                } else {
                    return "";
                }
            }},
            {field: "communicationMode", title: "交流方式", width: 100,formatter: function(value,row,index){
                if (row.communicationMode){
                    return row.communicationMode.name
                } else {
                    return "";
                }
            }},
            {field: "auditer", title: "审核人", width: 100,formatter: function(value,row,index){
                if (row.auditer){
                    return row.auditer.username
                } else {
                    return "";
                }
            }},
            {field: "auditState", title: "审核状态", width: 100,formatter: function(value,row,index){
                return value==1?"已审核":"未审核";

            }},

        ]],
        fit: true,
        fitColumns: true,
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        striped: true,
        pageNumber:1,
        pageSize:3,
        pageList:[3,5,10,20],
        toolbar: "#customerFollowRecord_tb"
    });
    //end列表信息


    //begin处理功能方法的对象
    var obj = {





        //begin刷新按钮
        reload: function () {
            $("#customerFollowRecord_datagrid").datagrid("reload");
        },
        //end刷新按钮

        //begin审核按钮
        audit: function () {
           var row =$("#customerFollowRecord_datagrid").datagrid("getSelected");
            if(!row){
                $.messager.alert('温馨提示', "请选择要审核的记录");
                return;
            }
            $.get("/customerFollowRecord/audit?id="+row.id,function (data) {
                if(data.success){
                    $.messager.alert('温馨提示', "审核成功");
                    $("#customerFollowRecord_datagrid").datagrid("reload");
                }else{
                    $.messager.alert('温馨提示', "审核失败");
                }
            })
        },
        //end审核按钮






    };
    //end处理功能方法的对象




    //begin处理功能方法对象,实际调用方法
    $("a[data-cmd]").click(function(){
        var cmd = $(this).data("cmd");
        obj[cmd]();
    });
    //end处理功能方法对象,实际调用方法


});

